<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserLoginCodesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_login_codes', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户id');
            $table->char('code', 64)->default('')->comment('登陆code')->unique();
            $table->tinyInteger('is_used')->default(0)->comment('是否已经被使用:0否,1是');
            $table->timestamp('expired_at')->comment('过期时间')->useCurrent();
            $table->string('ip', 15)->default('0.0.0.0')->comment('存储ip');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_login_codes');
    }
}
